feat(cli): add project memory integration#11364
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b97010a604
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)No new issues in the incremental diff since Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Previous Review Summaries (4 snapshots, latest commit 9713ad9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 9713ad9)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)These warnings are in incremental-only Files Reviewed (24 files)
Fix these issues in Kilo Cloud Previous review (commit e0a734e)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)These warnings are in incremental-only Files Reviewed (24 files)
Fix these issues in Kilo Cloud Previous review (commit 71882a3)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)These warnings are in incremental-only Files Reviewed (24 files)
Fix these issues in Kilo Cloud Previous review (commit 5ec40fc)Status: No Issues Found | Recommendation: Merge All three previously flagged issues have been resolved in commit
Files Reviewed (62 files)
Reviewed by gpt-5.4-20260305 · 243,311 tokens Review guidance: REVIEW.md from base branch |
13cf5d9 to
5ec40fc
Compare
7194bf7 to
e7e9efe
Compare
e0a734e to
9713ad9
Compare
9713ad9 to
794189b
Compare
e7e9efe to
0486646
Compare
catrielmuller
left a comment
There was a problem hiding this comment.
Please enforce this rule : https://github.com/Kilo-Org/kilocode/blob/main/packages/opencode/AGENTS.md?plain=1#L76
| void exit() | ||
| return true | ||
| } | ||
| // kilocode_change start - handle memory management as a harness action, not a chat prompt |
There was a problem hiding this comment.
move this to packages/opencode/src/kilocode/cli/cmd/tui/component/prompt/index.tsx
| <Show when={duration()}> | ||
| <span style={{ fg: theme.textMuted }}> · {Locale.duration(duration())}</span> | ||
| </Show> | ||
| {/* kilocode_change start - show per-turn memory usage in the assistant footer */} |
There was a problem hiding this comment.
move this to packages/opencode/src/kilocode/cli/cmd/tui/routes/session/index.tsx
| import { usePathFormatter } from "../../context/path-format" | ||
|
|
||
| type PermissionStage = "permission" | "always" | "reject" | ||
| // kilocode_change start - allow Kilo-owned permission renderers without per-permission shared branches |
There was a problem hiding this comment.
Try to move this to packages/opencode/src/kilocode/cli/cmd/tui/routes/session/permission.tsx
| } | ||
| }) | ||
|
|
||
| // kilocode_change start - memory data directories do not need plugin dependency installs |
There was a problem hiding this comment.
Integrate this with the config hooks on "packages/opencode/src/kilocode/config/config.ts"
| Effect.forkDetach, | ||
| ) | ||
| deps.push(dep) | ||
| // kilocode_change start - skip plugin package setup for memory-only .kilo data dirs |
| ) | ||
| } | ||
|
|
||
| function Memory(props: { api: TuiPluginApi }) { |
There was a problem hiding this comment.
Lets keep the footer clean, move the status information to the sidebar.
| yield* sessions.init() | ||
| yield* kilo.init() | ||
| yield* MemoryLifecycle.subscribe({ bus, sessions, summary, provider, memory }) | ||
| // kilocode_change start - invalidate enabled cache on every memory state mutation (properties.directory holds the memory root) |
There was a problem hiding this comment.
Remove the kilo markers on the kilo owned files
|
|
||
| // kilocode_change start - persistently prune stale tool outputs when payload is already large | ||
| const [skills, env, instructions] = yield* Effect.all([ | ||
| const enabled = yield* KiloSessionPrompt.memoryToolEnabled({ ctx }) // kilocode_change |
There was a problem hiding this comment.
Move this to "packages/opencode/src/kilocode/session/prompt.ts"
| const match = text?.match(/^gitdir:\s*(.+)$/m) | ||
| if (!match?.[1]) return dir | ||
| const git = path.resolve(dir, match[1]) | ||
| return checkout(common(git)) ?? dir |
There was a problem hiding this comment.
Can we validate that this gitdir belongs to the current checkout before using it as the memory identity? A workspace-controlled .git file can point at another local checkout, which would make this workspace load and expose Kilo memory from that other project.
| }) | ||
| if (!state.enabled || !state.capture.turnClose) return yield* skip("disabled") | ||
| const now = Date.now() | ||
| const messages = yield* input.sessions.messages({ sessionID: input.sessionID }) |
There was a problem hiding this comment.
Can this use a bounded message window instead of sessions.messages without limit? That path pages the whole transcript, so turn-close memory capture rereads long session history every turn.
| const completed = !input.reason || input.reason === "completed" | ||
| // Echo = short lookup answered from memory with no file changes. Long recall-assisted answers | ||
| // (research, investigations) carry new content and must still be digested. | ||
| const echo = !durable && assistant.length < 1200 && recalledMemory(turn) |
There was a problem hiding this comment.
Can this echo check include all assistant steps for the current user turn? latest() returns the final answer, but kilo_memory_recall can run in an earlier assistant step, so recalled facts can be saved back as new memory.
| skipped.push(rejected) | ||
| return false | ||
| } | ||
| const source = duplicate(`${item.key} ${item.text}`, input.items) |
There was a problem hiding this comment.
Could this skip valid memory before the file/section-aware applier sees it? This token-overlap check runs across all stored items, so a correction and a project fact with similar words can be treated as duplicates even though MemoryOperations.apply would keep them separate.
Issue
No linked issue. Follow-up CLI integration PR stacked on #11355.
Context
#11355 adds the core project memory package. This PR wires that package into the CLI so project memory is available from the TUI, agent prompts, server API, SDK, and Kilo-specific tools.
The goal is to keep the reusable memory implementation in the base PR while making the CLI consume it through Kilo-owned integration points where possible.
Implementation
memory_saveandmemory_recalltools plus prompt/tool-registry integration so agents can persist and retrieve project context.packages/opencode/src/kilocode/.Reviewer attention
Screenshots / Video
How to Test
Manual/local verification
Agent verification performed:
git push -u origin johnnyeric/memory-cli-integrationran the pre-push hook.bun turbo typechecksuccessfully across the workspace.Reviewer test steps
packages/opencode/, run the focused memory tests, for examplebun test ./test/kilocode/memory/memory-core.test.ts ./test/kilocode/memory/memory-capture.test.ts ./test/kilocode/memory/memory-save-tool.test.ts ./test/kilocode/memory/memory-recall-tool.test.ts ./test/kilocode/server/httpapi-memory.test.ts.Checklist
Depends on #11355.